package com.gjw.style;

import com.gjw.planeWar.PropertyMgr;

import java.awt.image.BufferedImage;

/**
 * @author gjw19
 * @date 2019/5/12
 */
public class Style {
    // 坦克
    public static BufferedImage heroPlane;
    public static BufferedImage enemyPlane;
    // 定义多个子弹图片
    public static BufferedImage bullet;
    public static BufferedImage background;
    public static BufferedImage gameOver;
    private static final Style INSTANCE = new Style();

    AbastractFactory factory;

    static {
        // 从配置文件中获取初始风格
        int styleNum = PropertyMgr.getInt("initStyleNum");
        Style.getINSTANCE().changeStyle(styleNum);
    }

    private Style() {

    }

    public static Style getINSTANCE() {
        return INSTANCE;
    }

    public void changeStyle(int num) {
        switch (num) {
            case 1:
                factory = ImageSketchFactory.getINSTANCE();
                break;
            case 2:
                factory = ImageRaidenFactory.getINSTANCE();
        }
        HeroPlaneImage heroPlaneImage = factory.createHeroPlane();
        heroPlane = heroPlaneImage.createHeroPlaneImg();
        EnemyPlaneImage enemyPlaneImage = factory.createEnemyPlane();
        enemyPlane = enemyPlaneImage.createEnemyPlaneImg();
        BulletImage bulletImage = factory.createBullet();
        bullet = bulletImage.createBulletImg();
        BackgroundImage backgroundImage = factory.createBackground();
        background = backgroundImage.createbackgroundImg();
        GameOverImage gameOverImage = factory.createGameOver();
        gameOver = gameOverImage.createGameOverImg();
    }
}
